/*
 * @Author: szx
 * @Date: 2021-11-12 13:40:25
 * @LastEditTime: 2021-11-12 13:45:57
 * @Description:
 * @FilePath: \leetcode\200-299\209\209.cpp
 */
#include <iostream>
#include <vector>
using namespace std;

class Solution {
   public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int l = 0, n = nums.size();
        int sum = 0;
        int cnt = INT_MAX;
        for (int i = 0; i < n; i++) {
            sum += nums[i];
            while (sum >= target) {
                if (cnt > i - l + 1) {
                    cnt = i - l + 1;
                }
                sum -= nums[l];
                l++;
            }
        }
        if (cnt == INT_MAX) return 0;
        return cnt;
    }
};

int main() { return 0; }